/**
 * 添加或者修改页面
 */
var IndentOrderInfoDlg = {
    data: {
        indentOrderNum: "",
        dealer: "",
        purchaseId: "",
        time: "",
        checkCode: "",
        remark: ""
    }
};

var check = {
    tableId: "checkTable"
};
layui.use(['form', 'admin', 'ax', 'layedit', 'table', 'tableSelect', 'layer'], function () {
    var $ = layui.jquery;
    var $ax = layui.ax;
    var form = layui.form;
    var admin = layui.admin;
    var layedit = layui.layedit;
    var lay_table = layui.table;
    var table = layui.table;
    var table_select = layui.tableSelect;
    var layer = layui.layer;

    //让当前iframe弹层高度适应
    admin.iframeAuto();

    var id = $("#indentId").val();
    console.log("传来的id是："+id);

    var Product = {
        tableId: "productTable"
    };

    //表格
    Product.initColumn = function () {
        return [[
            {field: 'id', hide: true, title: '主键'},
            {field: 'productName', hide: false, title: '产品'},
            {field: 'productModelName', sort: true, title: '产品型号'},
            {field: 'productOrderName', sort: true, title: '产品编号'},
            {field: 'price',sort:true,title:'价格'},
            {field: 'unitName',sort:true,title:'购买单位'},
            {field: 'orderNumbers',sort:true,title:'购买数量'},
            {field: 'orderAmount',sort:true,title:'总金额'}
        ]];
    };
    // 渲染表格
    var tableResult = table.render({
        elem: '#' + Product.tableId,
        url: Feng.ctxPath + '/purchaseOrders/getIndentOrderByDealer/'+$("#indentId").val(),
        page: true,
        height: "full-158",
        cellMinWidth: 100,
        cols: Product.initColumn()
    });



    //费用表格
    check.initColumn = function () {
        return [[
            {field: 'id', hide: true, title: '主键'},
            {field: 'nodeName', sort: true, title: '节点名称'},
            {field: 'auditorName', sort: true, title: '审核人'},
            {field: 'advice', sort: true, title: '审批意见'},
            {field: 'statusDesc', sort: true, title: '审核状态'},
            {field: 'time', sort: true, title: '审核时间'},
            {align: 'center', toolbar: '#tableBar', title: '操作'}
        ]];
    };

    // 渲染表格
    var tableResult = table.render({
        elem: '#' + check.tableId,
        url: Feng.ctxPath + '/checkDispatch/list/'+$("#indentId").val(),
        page: true,
        height: "full-158",
        cellMinWidth: 100,
        cols: check.initColumn()
    });

    //返回按钮
    $("#backupPage").click(function () {
        layer.close(index);
        window.location.href = Feng.ctxPath + '/dispatchOrderCheck'
    });

    $("#shenhe").click(function () {
        var id = $("#indentId").val();
        window.location.href =  Feng.ctxPath + '/afterIndentCommitCheck/shenheIndex?id=' + $("#id").val() + '&taskId=' +$("#taskId").val() //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']

    });
    $("#return").click(function () {
        var id = $("#indentId").val();
        window.location.href =  Feng.ctxPath + '/dispatchOrderCheck/returnIndex/' + id //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']

    })

});